// pages/home_workbench/index/index.js
const $app = getApp()
Component({
  properties: {},
  data: {
    baseUrl: $app.baseUrl || null,
    data: {}
  },
  lifetimes: { // 组件生命周期
    attached () { // 组件生命周期: 在组件实例进入页面节点树时执行
      // 获取菜单数据
      const menuData = $app.menuData_work
      const menuAuth = $app.menuAuth
      let obj = {}
      for (const k in menuData) {
        const b = menuData[k]
        const isIncludes = b.Auth.every(val => menuAuth.includes(val))
        if (!isIncludes) continue
        if (!obj[b.group]) obj[b.group] = {}
        obj[b.group][k] = b
      }
      this.setData({ data: obj })
    }
  },
  methods: {
    // ========== 跳转页面 ==========
    goPage (e) {
      const b = e.currentTarget.dataset.b
      console.log('goPage', b)
      wx.navigateTo({ url: b.path })
      wx.setNavigationBarTitle({ title: b.text })
    }
  }
})
